package com.qf.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.mapper.DtsPermissionMapper;
import com.qf.pojo.DtsPermission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author sunyamei
 * @version V1.0
 * @Project javase2203
 * @Package com.qf.service
 * @Description:
 * @Date 2022/7/25 20:30
 */
@Service
public class PermServiceImpl implements  PermService{

    @Autowired
    private DtsPermissionMapper permMapper;

    @Override
    public Set<String> queryPermByRoleIds(Integer[] roleIds) {
       //创建条件查询对象
        QueryWrapper<DtsPermission> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("role_id",roleIds);

        List<DtsPermission> permList = permMapper.selectList(queryWrapper);

        //遍历权限集合获取权限字符串
        Set<String> permSet = new HashSet<>();
        if (permList != null){
            for (DtsPermission permission : permList){
                permSet.add(permission.getPermission());
            }
        }


        return permSet;
    }
}
